<template>
  <div class="list-wrapper">
    <!-- <filtrate :fetchData="fetchData" :isShow="isShow"></filtrate> -->

    <div class="list-top">
      <div>
          <router-link to="/dashboard/courseTypeIncome">
            <span>五大类课程收入占比</span>
          </router-link>
          <span class="el-icon-arrow-right"></span>
          <span >{{info.name}}</span>
      </div>
		</div>


		<table class="list-table" border="0" cellspacing="0" cellpadding="0">
			<thead>
				<tr>
					<th>序号</th>
          <th>课程编号</th>
          <th>课程名称</th>
					<th>课程收入</th>
				</tr>
			</thead>
			<tbody>
				<tr v-for="(item,index) in list" @click="goCourseDetail(item.id)">
					<td>{{index+1}}</td>
					<td>{{item.code}}</td>
          <td>{{item.name}}</td>
          <td>{{item.money}}</td>
				</tr>
			</tbody>
		</table>
		<div class="pagination">
      <el-pagination v-if="list.length" @current-change="handleCurrentChange" :current-page="page" :page-size="10" layout="total, prev, pager, next, jumper" :total="total">
      </el-pagination>
      <div class="mess" v-if="!list.length">暂无数据</div>
    </div>
	</div>
</template>
<script>
import filtrate from "../filtrate";

export default {
  data() {
    return {
      isShow: true,
      page: 1,
      total: 0,
      id: "",
      filData: {},
      info: {},
      list: [],
    };
  },
  components: {
    filtrate
  },
  methods: {
    fetchData(time) {
      let data = {
        time: time ? time : "",
        type: this.id,
        page: this.page
      };
      this.apiPost("Dashboard/courseTypeIncomeDetail", data).then(res => {
        this.list = res.list;
        this.info = res.info;
        this.total = res.total;
      });
    },
    handleCurrentChange(val) {
      this.page = val;
      if (this.filData) {
        this.fetchData(this.filData.time);
      } else {
        this.fetchData();
      }
    },
    goCourseDetail(id) {
      window.open(SITE+"course/detail/"+id);
    }
  },
  created() {
    this.id = this.$route.params.id;
    this.filData = Lockr.get("filData");
    if (this.filData) {
      this.fetchData(this.filData.time);
    } else {
      this.fetchData();
    }
  }
};
</script>
<style lang="css" scoped>
.container {
  box-sizing: border-box;
  width: 100%;
  background: #ffffff;
  min-height: 100%;
  font-size: 14px;
  overflow: hidden;
}
.el-icon-arrow-right {
  margin: 0 5px;
  font-size: 14px;
}
.pagination {
  text-align: center;
  margin-top: 30px;
}
.mess{
  color: #666;
}
</style>
